﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Apollo
{
    public static class DateTimeHelper
    {
        private static DateTime BEGIN_UTC = new DateTime(1970, 1, 1);

        public static long ToUnixTime(DateTime datetime) {
            TimeSpan ts = new TimeSpan(datetime.Ticks - BEGIN_UTC.Ticks);

            return (long)Math.Round(ts.TotalMilliseconds, 0);
        }

        public static DateTime ToDateTime(long unixtime) {
            return BEGIN_UTC.AddSeconds(unixtime);
        }
    }
}
